﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace StoryMaker.Common
{
    public class PageCollection : ObservableCollection<Page> { }

    public class Page : NotifyPropertyChangedBase
    {
        public Page()
        {
            Shapes = new ObservableCollection<StoryShape>();
        }
        private string _text;
        public string Text
        {
            get { return _text; }
            set
            {
                if (_text != value)
                {
                    _text = value;
                    NotifyPropertyChanged("Text");
                }
            }
        }

        private ObservableCollection<StoryShape> _shapes;
        public ObservableCollection<StoryShape> Shapes
        {
            get { return _shapes; }
            set
            {
                if (_shapes != value)
                {
                    _shapes = value;
                    NotifyPropertyChanged("Shapes");
                }
            }
        }

        private Func<object, bool> _canDoDrop;
        public Func<object, bool> CanDoDrop
        {
            get
            {
                if (_canDoDrop == null)
                {
                    _canDoDrop = x => x is StoryShape;
                }
                return _canDoDrop;
            }
        }

        private Action<object> _dragIn;
        public Action<object> DragIn
        {
            get
            {
                if (_dragIn == null)
                {
                    _dragIn = new Action<object>(dragIn);
                }
                return _dragIn;
            }
        }

        private void dragIn(object newShape)
        {
            StoryShape shape = newShape as StoryShape;
            if (shape != null)
            {
                this.Shapes.Add(shape);
            }
        }
    }
}
